<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../css/login.css">
    <script src="../js/jquery-3.5.1.js"></script>
    <script src="../js/utils.js"></script>
</head>

<body>
    <form method="submit">
        <div class="title" ng-class="loginLogoClass">
            <div class="cloud"><img src="../img/cloud_b308865e15@2x.png" alt=""></div>
            <h4>使用 Smartisan ID 登录官网</h4>
        </div>
        <div class="content">
            <p class="err">用户名或密码错误</p>
            <p class="username"><span>账号 ： </span><input type="text"></p>
            <p class="password"><span>密码 ： </span><input type="password"></p>
            <button id="zhuce">注册</button>
            <button id="denglu">登 录</button>
        </div>
    </form>

    <div>
        <h3>Copyright © 2020 smartisan.com 版权所有</h3>
        <a href="https://beian.miit.gov.cn/#/Integrated/index">京 ICP 备 18020659 号 - 2</a>
    </div>
    <script>
        $('#denglu').on('click', function (e) {
            e.preventDefault()
            ajax({
                url: 'http://10.9.46.151:8080/usertest',
                method: 'GET',
                success(res) {
                    res = JSON.parse(res)
                    for (let i = 0; i < res.length; i++) {
                        if ($('.username > input')[0].value == res[i].username && $('.password > input')[0].value == res[i].password) {
                            window.location.href = `../index.html?username=${res[i].username}`
                        }
                    }

                    $('.err').addClass('active')

                }
            })
        })
        $('#zhuce').on('click', function (e) {
            e.preventDefault()
            window.location.href = './zhuce.html'
        })
    </script>
</body>

</html>